home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
011
/
fastbak.arc
/
QUERY.DOC
< prev
next >
Wrap
Text File
|
1986-02-01
|
2KB
|
55 lines
Documentation for QUERY2.COM
Author: Torsten Hoff
Date: 1/25/86
Language: 'C'
Syntax: QUERY2 valid_choices [message 1 [message 2 ... message n]]
Sample usage: query2 "123" "Press either 1,2, or 3 "
QUERY2 is a program that aids in writing interactive batch files. It takes
a minimum of one command line argument, and returns the ASCII code of the
user response as the DOS ERRORLEVEL.
Unlike other programs of this kind, any ASCII code except 0 (Ctrl-@) and
the Ctrl-Break combination (or Control-C) can be handled, including spaces.
Also, returning the ASCII code of the response rather than an index to the
string of choices eliminates the need to edit long batchfiles, since adding
or removing a choice will not change the ERRORLEVEL for any of the other
choices.
To include a space in either the string of valid choices, or in a message,
enclose the string in double quotes. For example, the following batchfile
will display a directory of either drive A, B, C, or the current drive:
[Listing of SHOWDIR.BAT]
echo off
cls
query2 "aAbBcC " "Enter the drive letter you wish a directory of, SPACE for default "
cls
if errorlevel 99 goto C
if errorlevel 98 goto B
if errorlevel 97 goto A
if errorlevel 67 goto C
if errorlevel 66 goto B
if errorlevel 65 goto A
if errorlevel 32 goto DEFAULT
:C
dir C: /w /p
goto END
:B
dir B: /w /p
goto END
:A
dir A: /w /p
goto END
:DEFAULT
dir /w /p
:END
pause
cls